/*
全局类，主要用来管理语言模块的加载等功能；
*/
window.GVoice = {
    curUsePlatform : 0,
    GVoiceIsInit : false,
    appID : "1369928819",
    appKey : "45e35d688f2e134a42adaff75e964899",
    GVoiceRoomID : 0,

    //初始化语音模块
    init : function(openID){
        if(local.GVoiceIsInit == false){
            if(local.curUsePlatform == 1){
              jsb.reflection.callStaticMethod("org/cocos2dx/javascript/JSCallJAVA", "GVoiceInit", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", local.appID, local.appKey, openID);
            }else if(local.curUsePlatform == 2){
              jsb.reflection.callStaticMethod("JSCallOC", "openGvoiceEngineAppID:andKey:andOpenID:", local.appID, local.appKey, openID);  
            }
            local.GVoiceIsInit = true;
        }
    },

    //语音加入房间
    joinRoom : function(roomID){
        if(local.curUsePlatform == 1){
          jsb.reflection.callStaticMethod("org/cocos2dx/javascript/JSCallJAVA", "GVoiceJoinRoom", "(Ljava/lang/String;)V", roomID);
        }else if(local.curUsePlatform == 2){
          jsb.reflection.callStaticMethod("JSCallOC", "GVoiceJoinRoom:", roomID);
        }
    },

    //语音退出房间
    quitRoom : function(roomID){
        if(local.curUsePlatform == 1){
          jsb.reflection.callStaticMethod("org/cocos2dx/javascript/JSCallJAVA", "GVoiceQuitRoom", "(Ljava/lang/String;)V", roomID);
        }else if(local.curUsePlatform == 2){
          jsb.reflection.callStaticMethod("JSCallOC", "GVoiceQuitRoom:", roomID);
        }
    },

    //语音开启听筒
    openListen : function(){
        if(local.curUsePlatform == 1){
          jsb.reflection.callStaticMethod("org/cocos2dx/javascript/JSCallJAVA", "GVoiceListenOpen", "()V");
        }else if(local.curUsePlatform == 2){
          jsb.reflection.callStaticMethod("JSCallOC", "GVoiceListenOpen");
        }
    },

    //语音关闭听筒
    closeListen : function(){
        if(local.curUsePlatform == 1){
          jsb.reflection.callStaticMethod("org/cocos2dx/javascript/JSCallJAVA", "GVoiceListenClose", "()V");
        }else if(local.curUsePlatform == 2){
          jsb.reflection.callStaticMethod("JSCallOC", "GVoiceListenClose");
        }
        
    },

    //语音开启麦克风
    openMic : function(){
        if(local.curUsePlatform == 1){
          jsb.reflection.callStaticMethod("org/cocos2dx/javascript/JSCallJAVA", "GVoiceMicOpen", "()V");
        }else if(local.curUsePlatform == 2){
          jsb.reflection.callStaticMethod("JSCallOC", "GVoiceMicOpen");
        }
    },

    //语音关闭麦克风
    closeMic : function(tag){
        if(local.curUsePlatform == 1){
          jsb.reflection.callStaticMethod("org/cocos2dx/javascript/JSCallJAVA", "GVoiceMicClose", "(I)V",tag);
        }else if(local.curUsePlatform == 2){
          jsb.reflection.callStaticMethod("JSCallOC", "GVoiceMicClose");
        }
    },

    //语音SDK poll操作
    gvoicePoll : function(){
      if(local.GVoiceIsInit == true)
        if(local.curUsePlatform == 1)
          jsb.reflection.callStaticMethod("org/cocos2dx/javascript/JSCallJAVA", "GVoicePoll", "()V");
        else
          jsb.reflection.callStaticMethod("JSCallOC","GVoicePoll");
    },
};

var local = window.GVoice;